package com.deltabot.networking.update;

import com.deltabot.settings.Client;

import java.net.*;
import java.io.*;

public class UpdateCheck {

    public static boolean newVersionAvailable(){
        URL url = null;
        try {
            url = new URL(Client.REMOTE_VERSION_TXT_URL());
        } catch (MalformedURLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        BufferedReader in = null;
        try {
            in = new BufferedReader(new InputStreamReader(url.openStream()));
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        try {
            Client.remoteVersion = Integer.parseInt(in.readLine());
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        try {
            in.close();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        return !(Client.remoteVersion == Client.REVISION);
    }

}
